package com.ibiz.test.entity.action;

import java.util.ArrayList;
import java.util.Iterator;

import org.dom4j.Document;
import org.springframework.test.annotation.Rollback;
import org.testng.Assert;
import org.testng.ITestContext;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.alibaba.fastjson.JSONObject;
import com.ibiz.test.util.DocXmlUtil;
import com.ibiz.test.util.IActionTest;

//@SpringBootTest(classes = Application.class)
public class BXD003 implements IActionTest
{
	private String testSn = "BXD003" ;
	
	@Override
	public String getTestSn() {
		return testSn ;
	}

	@DataProvider(name = "data")
	public Iterator<Object[]> prepareData(ITestContext testContext) throws Exception {
		// Excel xml 测试数据
		ArrayList<Object[]> data = new ArrayList<Object[]>();
		try {
			Document doc = (Document)testContext.getAttribute("doc") ;
			String strData = DocXmlUtil.findTestData(testSn,DocXmlUtil.DATA_DEACTION); 
			//User user = JSONObject.parseObject(strData, User.class);
			//data.add(new Object[] {  user }) ;
			data.add(new Object[] {  strData }) ;
		} catch (Exception e) {
			e.printStackTrace();
		}

		return data.iterator();
	}

	@Test(dataProvider = "data")
	@Rollback(true)
	public void test(String data) {
		// 执行实体行为
		if(data.equals("")) {
			Assert.assertTrue(false);
		}else {
			Assert.assertTrue(true);
		}
	}

}
